cmake_minimum_required(VERSION 3.20)
project(FilterAgent)

set(CMAKE_CXX_STANDARD 17)

if (MSVC)
    set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif ()

add_definitions(-D_WIN32)
add_definitions(-DSPDLOG_WCHAR_TO_UTF8_SUPPORT)

include(FetchContent)

FetchContent_Declare(json
        GIT_REPOSITORY
        https://github.com/nlohmann/json.git
        GIT_TAG v3.11.3
)
FetchContent_Declare(spdlog
        GIT_REPOSITORY
        https://github.com/gabime/spdlog.git
        GIT_TAG v1.12.0
)
FetchContent_Declare(fmt
        GIT_REPOSITORY
        https://github.com/fmtlib/fmt.git
        GIT_TAG 11.1.3
)

FetchContent_MakeAvailable(json spdlog fmt)

include_directories(${CMAKE_CURRENT_LIST_DIR}
        ${CMAKE_CURRENT_LIST_DIR}/include
        ${CMAKE_CURRENT_LIST_DIR}/include/common
        ${CMAKE_CURRENT_LIST_DIR}/include/utils
        ${CMAKE_CURRENT_LIST_DIR}/include/filters
        ${CMAKE_CURRENT_LIST_DIR}/include/ipc
        ${CMAKE_CURRENT_LIST_DIR}/../../common/utils/
)

add_executable(${PROJECT_NAME} src/main.cpp
        src/common/log.cpp
        src/common/config.cpp
        src/filter_service.cpp
        src/filters/path_filter.cpp
        src/filters/caller_filter.cpp
        src/filters/file_filter.cpp
        src/filters/custom_filter.cpp
        src/ipc/ioctl_channel.cpp
        src/utils/string_util.cpp
        src/utils/win_util.cpp
        include/utils/lru_cache.h
        ${CMAKE_CURRENT_LIST_DIR}/../../common/utils/thread_pool.cpp
)

target_link_libraries(${PROJECT_NAME} PRIVATE nlohmann_json::nlohmann_json spdlog::spdlog fmt::fmt version.lib Wtsapi32.lib)
